package ast

import (
	"bytes"
	"fmt"
	"fox/src/lexer"
)

type LetStatement struct {
	Token lexer.Token
	Name  *Identifier
	Value Expression
}

func (ls *LetStatement) statementNode()       {}
func (ls *LetStatement) TokenLiteral() string { return ls.Token.Literal }
func (ls *LetStatement) StringTree() string {
	fmt.Println(ls)
	var out bytes.Buffer

	out.WriteString(ls.TokenLiteral() + " ")
	out.WriteString(ls.Name.StringTree())
	out.WriteString(" = ")
	if ls.Value != nil {
		out.WriteString(ls.Value.TokenLiteral())
	}

	// out.WriteString("Let{Token:" + fmt.Sprintf("%+v", ls.Token) + ",Name:'', Value:'" + ls.Value.TokenLiteral() + "'}")

	return out.String()
	// return fmt.Sprintf("%+v", ls)
}
